package ntd.util.frame.javacv;

import cn.hutool.setting.dialect.Props;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

@Data
@Accessors(chain = true)
public class AiModelBean {
    private String type;//模型类型
    private String serverUrl;//服务器地址
    private String ftpIp;//服务器地址
    private String videoResultPath;//视频分析结果目录标识
    private String imageResultPath;//图片分析结果目录标识
    private String[] objectType;//检测到的物体类型

    private Integer ftpPort = 21;
    private String ftpUsername = "ftp";
    private String ftpPassword = "zzfm12345@";


//    public static AiModelBean initType(String type) {
//        return new AiModelBean().setType(type);
//    }
//
//    public static AiModelBean initServerUrl(String serverUrl) {
//        return new AiModelBean().setServerUrl(serverUrl);
//    }
//
//    public static AiModelBean initFtpIp(String ftpIp) {
//        return new AiModelBean().setFtpIp(ftpIp);
//    }


    public static List<AiModelBean> getModelList(){
        //获取配置文件
        Props prop = new Props("ai-config.properties");

        //AI服务器接口
        String url = "http://%s:8081/vision?model=";
        List<AiModelBean> list = new ArrayList<>();
        //人体模型
        String person_url = prop.getProperty("ai-person-server-url");
        list.add(new AiModelBean().setType("Person").
                setServerUrl(String.format(url,person_url)).
                setFtpIp(person_url).
                setVideoResultPath("person_video")
                .setImageResultPath("person_image")
                .setObjectType(new String[]{"person"}));
        //水藻
        String algae_url = prop.getProperty("ai-algae-server-url");
        list.add(new AiModelBean().setType("Algae").
                setServerUrl(String.format(url,algae_url))
                .setFtpIp(algae_url)
                .setVideoResultPath("algae_video").setImageResultPath("algae_image")
                .setObjectType(new String[]{"algae"}));
        //垃圾
        String garbage_url = prop.getProperty("ai-garbage-server-url");
        list.add(new AiModelBean().setType("WaterGarbage")
                .setServerUrl(String.format(url,garbage_url))
                .setFtpIp(garbage_url)
                .setVideoResultPath("water_garbage_video")
                .setImageResultPath("water_garbage_image")
                .setObjectType(new String[]{"DrinkBottle","FastFoodBox","FouledPlastic","RingPullCan"}));
                // 对应中文名：饮料瓶、快餐盒、塑料袋、易拉罐

        return list;
    }
}
